package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import GUI.cReportGUI;

/**
 * The Class cReportController.
 * Controller for customer characterization report producing activity
 */
public class cReportController {
	
	/** The report gui. */
	private cReportGUI cReportGUI;
	
	/** The previous controller. */
	private ReportsController prev;
	
	/**
	 * Instantiates a new report controller.
	 *
	 * @param cReportGUI the report gui
	 */
	public cReportController(cReportGUI cReportGUI){
		this.cReportGUI=cReportGUI;
		this.cReportGUI.addBackActionListener(new BackListener());	
		this.cReportGUI.setVisible(true);	
	}
	
	
	/**
	 * The listener interface for receiving back events.
	 * The class that is interested in processing a back
	 * event implements this interface, and the object created
	 * with that class is registered with a component using the
	 * component's <code>addBackListener<code> method. When
	 * the back event occurs, that object's appropriate
	 * method is invoked.
	 *
	 * @see BackEvent
	 */
	class BackListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent e) {
			LoginController.mainWindow.setContentPane(prev.getrGUI());
		}	
	}
	
	/**
	 * Sets the previous controller.
	 *
	 * @param prev the new previous controller
	 */
	public void setPrev(ReportsController prev) {
		this.prev = prev;
	}
}
